package com.jxmcloud.business.cut.constants;

import com.jxmcloud.business.cut.config.ConfigProperties;
import com.jxmcloud.business.cut.util.SpringUtils;

/**
 * Redis 锁相关常量
 */
public class CutRedisConstant {
    //一天后过期
    public static final long EXPIRED_TIME = 24 * 60 * 61;

    private final static String CUT_USER_INFO_KEY = "CUT:USER_INFO_CACHE:";

    /**
     * 获取用户信息缓存 key
     *
     * @param uid 账号
     * @return 用户信息缓存 key
     */
    public static String  getUserInfoKey(String uid) {
        ConfigProperties bean = SpringUtils.getBean(ConfigProperties.class);
        String activeProfile = bean.getActiveProfile();
        /**
         * 环境隔离，如果是dev或者test，获取用户缓存信息代环境标签，演示服或者正式服则不带
         */
        if(activeProfile.equals("dev") || activeProfile.equals("test")) {
            return CUT_USER_INFO_KEY + activeProfile + ":" + uid;
        }
        return CUT_USER_INFO_KEY + uid;
    }


    /*--------------------------------    REDIS_LOCK_KEY    --------------------------------*/

    /**
     * 用户登录锁
     * @param account
     * @return
     */
    public static String cutLoginLock(String account) {
        return "CUT:LOGIN:LOCK:ACCOUNT" + account;
    }

    public static String RELOAD_DATA_CONFIG = "RELOAD_DATA_CONFIG";
    /**
     * 用户转盘信息
     */
    public static String TURN_USER_LOCK = "turn:user:lock:";
    /**
     * 购买加速礼包
     */
    public static String buySpeedGiftLockKey(String session) {
        return "BUY_SPEED_GIFT_LOCK_KEY: " + session;
    }

    /**
     * 用户登录跳转Key
     */
    public static String userLoginXlLockKey(String account) {
        return "USER_LOGIN_XL_LOCK_KEY: " + account;
    }
}
